package ai2;

import java.util.ArrayList;

public class Rule {
	
	private ArrayList<String> antecedents = new ArrayList<String>();
	private ArrayList<String> assertions = new ArrayList<String>();
	
	public Rule() {
		
	}
	// create a rule with the first antecedent added
	public Rule(String firstAntecedent) {
		addNewAntecedent(firstAntecedent);
	}
	// create a rule from a list of antecedents and a list of assertions
	public Rule(ArrayList<String> antecedents, ArrayList<String> assertions) {
		this.antecedents = antecedents;
		this.assertions = assertions;
	}
	
	// return the list of all the antecedents
	public ArrayList<String> getAntecedents() {
		return antecedents;
	}
	// replace the entire antecedent list with a new one
	public void setAntecedents(ArrayList<String> antecedents) {
		this.antecedents = antecedents;
	}
	// add a new antecedent
	public void addNewAntecedent(String antecedent) {
		antecedents.add(antecedent);
	}
	// remove an antecedent and return it
	public String removeAntecedent(int index) {
		return antecedents.remove(index);
	}
	// clear all the antecedents
	public void clearAntecedents() {
		antecedents.clear();
	}
	// get the list of all the assertions
	public ArrayList<String> getAssertions() {
		return assertions;
	}
	// replace the entire assertions list with a new one
	public void setAssertions(ArrayList<String> assertions) {
		this.assertions = assertions;
	}
	// add a new assertion
	public void addNewAssertion(String assertion) {
		assertions.add(assertion);
	}
	// remove an assertion and return it
	public String removeAssertion(int index) {
		return assertions.remove(index);
	}
	// clear all the assertions
	public void clearAssertions() {
		assertions.clear();
	}
	// toString
	public String toString() {
		return "RL -- antecedents: \n" + antecedents + "\n" + "RL -- assertions: \n" + assertions;
	}
}